<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>树之操作 - jQuery EasyUI 演示</title>
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../../jquery.min.js"></script>
	<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
	<h2 title="Tree Actions">树之操作</h2>
	<p title="Click the buttons below to perform actions.">　　点击下面的按钮即可执行相应的操作。</p>
	<div style="margin:20px 0;">
		<a href="#" class="easyui-linkbutton" onclick="collapseAll()" title="CollapseAll">全部收缩</a>
		<a href="#" class="easyui-linkbutton" onclick="expandAll()" title="ExpandAll">全部展开</a>
		<a href="#" class="easyui-linkbutton" onclick="expandTo()" title="ExpandTo">展开至当前</a>
		<a href="#" class="easyui-linkbutton" onclick="getSelected()" title="GetSelected">获取选中项</a>
	</div>
	<div class="easyui-panel" style="padding:5px">
		<ul id="tt" class="easyui-tree" data-options="url:'tree_data1.json',method:'get',animate:true"></ul>
	</div>
	<script type="text/javascript">
		function collapseAll(){
			$('#tt').tree('collapseAll');
		}
		function expandAll(){
			$('#tt').tree('expandAll');
		}
		function expandTo(){
			var node = $('#tt').tree('find',113);
			$('#tt').tree('expandTo', node.target).tree('select', node.target);
		}
		function getSelected(){
			var node = $('#tt').tree('getSelected');
			if (node){
				var s = node.text;
				if (node.attributes){
					s += ","+node.attributes.p1+","+node.attributes.p2;
				}
				alert(s);
			}
		}
	</script>
</body>
</html>